import subprocess  # Import subprocess module
import os  # We will use the exists() function from this module to know if the file was created.

class XlsToXlsxUtils:

    @staticmethod
    def convert_file_to_xlsx(file_path, output_dir):
        subprocess.run(
            f'/usr/bin/libreoffice \
            --headless \
            --convert-to xlsx \
            --outdir {output_dir} {file_path}', shell=True)
        xlsx_file_path = f'{output_dir}{file_path.rsplit("/", 1)[1].split(".")[0]}.xlsx'
        if os.path.exists(xlsx_file_path):
            return xlsx_file_path
        else:
            return None
